#!/usr/bin/env python
# -*- coding: utf-8 -*-
# 模型验证

from pydantic import BaseModel
from typing import List, Optional


class BaseItem(BaseModel):
    title: str
    description: Optional[str] = None


class ItemModel(BaseItem):
    pass


class ItemOut(BaseItem):
    id: int
    owner_id: int

    class Config:
        from_attributes = True


class BaseUser(BaseModel):
    email: str


class UserModel(BaseUser):
    """请求参数模型"""
    password: str


class UserOut(BaseUser):
    """响应模型"""
    id: int
    is_active: bool
    items: List[ItemOut]

    class Config:
        from_attributes = True
